package com.woniu.his.dms.service.impl;



import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.his.dms.common.DmsResultCode;
import com.woniu.his.dms.infra.mapper.CaseDiseModelRelationMapper;
import com.woniu.his.dms.infra.model.CaseDiseModelRelation;
import com.woniu.his.dms.infra.model.CaseDiseRelation;
import com.woniu.his.dms.infra.model.Dise;
import com.woniu.his.dms.service.CaseDiseModelRelationService;
import com.woniu.his.dms.service.DiseService;
import com.woniu.his.exception.HisException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * @version: java version 1.8
 * @Author: ZJH
 * @description:
 * @date: 2022-11-30 14:40
 */
@Service
public class CaseDiseModelRelationServiceImpl extends ServiceImpl<CaseDiseModelRelationMapper, CaseDiseModelRelation> implements CaseDiseModelRelationService {

    @Resource
    private DiseService diseService;

    @Override
    public void createCaseDiseRelation(Long caseModelId, Long diseId) {
        Dise dise = diseService.getById(diseId);
        if(dise==null) throw new HisException(DmsResultCode.DISE_NOT_EXISTS);
        CaseDiseModelRelation caseDiseModelRelation = new CaseDiseModelRelation();
        caseDiseModelRelation.setDiseId(diseId);
        caseDiseModelRelation.setCaseModelId(caseModelId);
        caseDiseModelRelation.setDiseName(dise.getNameDise());
        save(caseDiseModelRelation);
    }

}
